import dayjs from 'dayjs';
import React from 'react';
import styles from './index.modules.less';

function PadHeader({ extra }) {
  const [time, setTime] = React.useState(dayjs().format('YYYY-MM-DD HH:mm:ss'));

  const interTime = () => {
    setInterval(() => {
      setTime(dayjs().format('YYYY-MM-DD HH:mm:ss'));
    }, 1000);
  };

  React.useEffect(() => {
    interTime();

    return () => {};
  }, []);

  return (
    <div className={styles.container}>
      <div className={styles.left}>
        <div>监室信息交互终端A区201室{extra}</div>
      </div>
      <div className={styles.right}>
        <div>{time}</div>
      </div>
    </div>
  );
}

export default PadHeader;
